import {Component, OnInit} from '@angular/core';
import {HttpClient} from '@angular/common/http';
import {Router} from '@angular/router';

@Component({
  selector: 'app-admin-tag',
  templateUrl: './admin-tag.component.html',
  styleUrls: ['./admin-tag.component.css']
})
export class AdminTagComponent implements OnInit {
  tags: any;

  constructor(private http: HttpClient, private router: Router) {
  }

  ngOnInit(): void {
    this.getAllTags();
  }

  getAllTags(): void {
    const url = '/api/tag/getAllTag';
    this.http.get(url).subscribe((resp: any) => {
      if (resp.code === 200) {
        const data = resp.data;
        this.tags = data;
      } else {

      }
    }, (error) => {
      if (error.status === 403 || error.status === 501) {
        this.router.navigateByUrl('/permision-error');
      }
    });
  }

}
